package Messages;

import java.io.IOException;
import java.sql.SQLException;


import ocsf.server.ConnectionToClient;
import server.SQLConnection;
/**
 * this class implements the editing of new title in db
 * @author Ron Shenkerman
 * @author Gabi Revah
 * @author Aviad Almog
 * @author Ivan Onyshchenko
 */
public class MessageNewTitle {
private ConnectionToClient client;
/**
 * constractor of this class 
 * @param client
 */
	public MessageNewTitle(ConnectionToClient client) {
		// TODO Auto-generated constructor stub
		super();
		this.client=client;
	}
/**
 * setting new title to the book in the DB 
 * @param str
 * @throws SQLException
 * @throws IOException
 */
	public void NewTitle(String[] str) throws SQLException, IOException {
		// TODO Auto-generated method stub

		System.out.println("Getting new Title");

		SQLConnection sc = new SQLConnection();
		java.sql.PreparedStatement ps = sc.getConnection().prepareStatement("Update DB1.books SET Title=? WHERE ID=?");
		ps.setString(1, str[2]);
		ps.setString(2, str[1]);
		ps.executeUpdate();
		client.sendToClient("NewTitle");
	
		ps.close();
	
		
	
		
		
		
	}

}
